package com.ict.web.controller.yzq;


import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.enums.BusinessType;
import com.ict.web.dto.ExchangeExpertAssignDto;
import com.ict.web.dto.ExchangeExpertDto;
import com.ict.web.dto.ExtractRuleBeginDto;
import com.ict.web.dto.ExtractRuleEditDto;
import com.ict.web.service.IExtractRuleService;
import com.ict.web.vo.ExpertInformationSheetDetailVo;
import com.ict.web.vo.ExtractRuleBeginVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


/**
 * 抽取规则Controller
 * 
 * @author xc
 * @date 2022-02-25
 */
@Api(tags = "抽取规则")
@RestController
@RequestMapping("/extractRule")
public class ExtractRuleController extends BaseController
{

    @Autowired
    private IExtractRuleService extractRuleService;

    /**
     * 获取开始抽取参数对象
     */
    @GetMapping("/getParameter")
    @ApiOperation(value ="获取开始抽取参数对象")
    public List<ExtractRuleBeginDto> getParameter()
    {
        return extractRuleService.getParameter();
    }

    /**
     * 开始抽取
     */
//    @PreAuthorize("@ss.hasPermi('web:extractRule:beginExtract')")
    @PostMapping("/beginExtract")
    @ApiOperation(value ="开始抽取")
    public List<ExtractRuleBeginVo> beginExtract(@RequestBody  List<ExtractRuleBeginDto> list)
    {
        return extractRuleService.selectExtractRuleList(list);
    }
    /**
     * 更换专家（修改规则）-随机抽取、按条件抽取
     */
    @PreAuthorize("@ss.hasPermi('web:extractRule:updateRuleExchangeExpert')")
    @PostMapping("/updateRuleExchangeExpert")
    @ApiOperation(value ="更换专家（修改规则）-随机抽取、按条件抽取")
    public ExpertInformationSheetDetailVo updateRuleExchangeExpert(@RequestBody ExchangeExpertDto dto)
    {
        return extractRuleService.updateRuleExchangeExpert(dto);
    }
    /**
     * 更换专家查看专家信息-随机抽取、按条件抽取
     */
    @GetMapping("/selectExchangeExpert")
    @ApiOperation(value ="更换专家-随机抽取、按条件抽取")
    public ExpertInformationSheetDetailVo selectExchangeExpert(ExchangeExpertDto dto)
    {
        return extractRuleService.selectExchangeExpert(dto);
    }
    /**
     * 更换专家查看-指定专家信息
     */
    @GetMapping("/{reviewTaskId}")
    @ApiOperation(value ="指定专家list(查询未抽取出来的专家)")
    public ExpertInformationSheetDetailVo exchangeExpertList(@PathVariable  Long reviewTaskId,Long expertId,Long extractExpertId)
    {
        return extractRuleService.exchangeExpert(reviewTaskId, expertId,extractExpertId);
    }

    /**
     * 指定专家list(查询未抽取出来的专家)
     */
    @GetMapping("/exchangeExpertAssignList/{reviewTaskId}")
    @ApiOperation(value ="指定专家list(查询未抽取出来的专家)")
    public List<ExpertInformationSheetDetailVo> exchangeExpertAssignList(@PathVariable  Long reviewTaskId)
    {
        return extractRuleService.exchangeExpertAssignList(reviewTaskId);
    }
    /**
     * 更换专家
     */
    @PutMapping("/exchangeExpertAssign")
    @ApiOperation(value ="更换专家")
    public AjaxResult exchangeExpertAssign(@Valid @RequestBody ExchangeExpertAssignDto exchangeExpertAssignDto)
    {
        return extractRuleService.exchangeExpertAssign(exchangeExpertAssignDto);
    }
    /**
     * 修改抽取规则
     */
    @PutMapping("/update")
    @Log(title = "修改抽取规则", businessType = BusinessType.UPDATE)
    @ApiOperation(value ="修改抽取规则")
    public long editSave(@Valid @RequestBody ExtractRuleEditDto dto)
    {
        return extractRuleService.updateExtractRule(dto);
    }

}
